using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;

using System.ComponentModel;

namespace ContentPipeline
{
    /// <summary>
    /// This class will be instantiated by the XNA Framework Content Pipeline
    /// to apply custom processing to content data, converting an object of
    /// type TInput to TOutput. The input and output types may be the same if
    /// the processor wishes to alter data without changing its type.
    ///
    /// This should be part of a Content Pipeline Extension Library project.
    ///
    /// TODO: change the ContentProcessor attribute to specify the correct
    /// display name for this processor.
    /// </summary>
    [ContentProcessor(DisplayName = "Model - ContentPipeline")]
    public class UNModelProcessor : ModelProcessor
    {
        [DisplayName("Custom Effect")]
        [DefaultValue("Effect")]
        [Description("The custom effect applied to the model.")]
        public string CustomEffect
        {
            get { return customEffect; }
            set { customEffect = value; }
        }
        private string customEffect = "Effect";

        protected override MaterialContent ConvertMaterial(MaterialContent input, ContentProcessorContext context)
        {

            OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();
            processorParameters.Add("CustomEffect", customEffect);
            processorParameters["ColorKeyColor"] = this.ColorKeyColor;
            processorParameters["ColorKeyEnabled"] = this.ColorKeyEnabled;
            processorParameters["TextureFormat"] = this.TextureFormat;
            processorParameters["GenerateMipmaps"] = this.GenerateMipmaps;
            processorParameters["ResizeTexturesToPowerOfTwo"] =
                                                        this.ResizeTexturesToPowerOfTwo;

            return context.Convert<MaterialContent, MaterialContent>(input,
                                                "UNMaterialProcessor", processorParameters);
        }
    }
}
